#!/bin/bash

#Check if Git is installed, and install it if not
if ! command -v git &> /dev/null; then
  echo "Git is not installed. Installing..."
  xcode-select --install
  git --version
fi

#Check if Python 3.10.6 is installed, and install it if not
if ! python3 --version | grep -qE "Python (3\.10\.6|3\.10\.[7-9]|3\.11|3\.12)"; then
  echo "Python 3.10.6 is not installed. Installing..."
  brew install python@3.10
  python3 --version
fi

#Install and start ollama
# echo "$(pwd)"
nohup $(pwd)/build/macos/ollama serve  > $(pwd)/build/macos/ollama.log 2>&1 &
# $(pwd)/build/macos/ollama --version


#Install and start stable-diffusion-webui
brew install cmake protobuf rust wget
echo "Installing stable-diffusion-webui..."
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui $(pwd)/build/macos/stable-diffusion-webui
$(pwd)/build/macos/stable-diffusion-webui/webui.sh